import request from '@/utils/request'

/**
 * 查询所有业务组类别
 */
export function getBusinessAll() {
  return request({
    url: '/call-center/api/v1/businessGroup/',
    method: 'get'
  })
}

/**
 * 分页查询业务组类别
 * @param {*} params
 */
export function getBusinessPage(params) {
  return request({
    url: '/call-center/api/v1/businessGroup/page',
    method: 'post',
    data: params
  })
}

/**
 * 业务组名称添加
 * @param {*} params
 */
export function addBusiness(params) {
  return request({
    url: '/call-center/api/v1/businessGroup',
    method: 'post',
    data: params
  })
}

/**
 * 业务数据名称修改
 * @param {*} params
 */
export function updateBusiness(params) {
  return request({
    url: '/call-center/api/v1/businessGroup',
    method: 'put',
    data: params
  })
}

/**
 * 删除业务数据名称ById
 * @param {*} id
 */
export function deleteBusiness(id) {
  return request({
    url: `/call-center/api/v1/businessGroup/${id}`,
    method: 'delete'
  })
}

/**
 * 新增业务组成员信息
 * @param {*} groupId 业务组ID
 * @param {*} params 需向业务组添加人员
 */
export function addBusinessMembers(groupId, params) {
  return request({
    url: `/call-center/api/v1/businessGroup/members/${groupId}`,
    method: 'post',
    data: params
  })
}
// 分页查询业务组人员
export function getBusinessMembers(params, groupId) {
  return request({
    url: `/call-center/api/v1/businessGroup/member/page/${groupId}`,
    method: 'post',
    data: params
  })
}

/**
 * 新增成员信息
 * @param {string} accountNo 用户账号
 * @param {array} groupIds 业务组ID集合
 */
export function postBusinessMembers(accountNo, groupIds) {
  return request({
    url: `/call-center/api/v1/businessGroup/members/groups/${accountNo}`,
    method: 'POST',
    data: groupIds
  })
}

/**
 * 删除业务组成员
 * @param {*} id 业务组人员ID
 */
export function deleteBusinessMembers(ids) {
  return request({
    url: `/call-center/api/v1/businessGroup/members`,
    method: 'delete',
    data: ids
  })
}

/**
 * 根据职员账号查询职员所属业务组
 * @param {string} accountNo 职员账号
 */
export function getCurrentBusiness(accountNo) {
  return request({
    url: `/call-center/api/v1/businessGroup/members/groups/${accountNo}`,
    method: 'get'
  })
}

/**
 * 按成员账号及业务组ID集合批量删除账号所属的业务组成员信息
 * @param {string} accountNO 用户账号
 * @param {array} data 业务组账号
 */
export function deleteBusinessByAccount(accountNO, data) {
  return request({
    url: `/call-center/api/v1/businessGroup/members/account/${accountNO}`,
    method: 'delete',
    data
  })
}
